

clear 
g sect=1 
drop if sect==1
save $output, replace 


forvalues x = 1(1)$max{
*local x=1
use naics_id_conc_database_blkgp, clear 
sort naics 
egen sect=group(naics) 
keep if sect==`x' 
sort id_conc
merge 1:1 id_conc using $base_demo
tab t, gen(time)
keep $condition 
replace $dep=0 if $dep==.  
g _= $dep!=0 
egen nb_block_active=sum(_) 

nbreg $dep $explanatory $condition, nolog ro 
	
		foreach i in $explanatory {
		g coef_`i'=_b[`i'] 
		g se_`i'=_se[`i'] 
		}
	
keep if $dep>0 // to keep lines with info on the naics sect
duplicates drop naics, force // one elasticity per naics 
keep sect naics coef_* se_*  nb_block_active	
append using $output 
save $output, replace 	
}





